package net.apexes.demo.codegen.ormlite.column;

import net.apexes.commons.ormlite.Column;
import net.apexes.commons.ormlite.ForeignKey;
import net.apexes.commons.ormlite.Index;
import net.apexes.demo.codegen.ormlite.column.base.QEntityBase;
import net.apexes.demo.codegen.ormlite.entity.ShopUser;

/**
 * QShopUser is a ORMLite query type for ShopUser
 * @see ShopUser
 */
public class QShopUser extends QEntityBase<ShopUser> {

    public static final QShopUser $ = new QShopUser("SHOP_USER");

    public final Column shopId = field("shopId").columnName("SHOP_ID").varchar(22).notNull().build();

    public final Column userId = field("userId").columnName("USER_ID").varchar(22).notNull().build();

    public class Indexs {

        public final Index constraintIndex2a = index("CONSTRAINT_INDEX_2A").column(userId).build();

        public final Index constraintIndex2a7 = index("CONSTRAINT_INDEX_2A7").column(shopId).build();

        public final Index primaryKey2a = index("PRIMARY_KEY_2A").unique().column(id).build();

    }

    public final Indexs ix = new Indexs();

    public class ForeignKeys {

        public final ForeignKey constraint2a7 = foreignKey(userId, "AUTH_USER", "ID");

        public final ForeignKey constraint2a77 = foreignKey(shopId, "SHOP", "ID");

    }

    public final ForeignKeys fk = new ForeignKeys();

    public QShopUser(String tableName) {
        super(ShopUser.class, tableName);
    }

    @Override
    public ShopUser newInstance() {
        return new ShopUser();
    }

    @Override
    public Object getFieldValue(ShopUser instance, String fieldName) {
        switch (fieldName) {
            case "shopId":
                return instance.getShopId();
            case "userId":
                return instance.getUserId();
            default:
                return super.getFieldValue(instance, fieldName);
        }
    }

    @Override
    public void setupFieldValue(ShopUser instance, String fieldName, Object value) {
        switch (fieldName) {
            case "shopId":
                instance.setShopId((java.lang.String) value);
                break;
            case "userId":
                instance.setUserId((java.lang.String) value);
                break;
            default:
                super.setupFieldValue(instance, fieldName, value);
                break;
        }
    }

}

